package com.securitytrace.client.userlistener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class UserListenerController implements ActionListener {

	private UserActionListener userActionlistener;
	
	public UserListenerController(UserActionListener userActionListener) {
		this.userActionlistener = userActionListener;
	}
	
	@Override
	public void actionPerformed(ActionEvent event) {
		String methodName = event.getActionCommand();
		try {
			Method excuteMethod = userActionlistener.getClass().getDeclaredMethod(methodName, new Class<?>[]{});
			excuteMethod.invoke(userActionlistener, new Object[]{});
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
	}
}
